﻿<storeControls:StoreApplicationPage x:Class="Store.WP7.Views.OrderDetailsPage"
                                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                                    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                                    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                                    xmlns:storeControls="clr-namespace:Store.WP7.Controls;assembly=Store.WP7.Controls"
                                    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                                    xmlns:behaviors="clr-namespace:Store.WP7.Framework.Interactions;assembly=Store.WP7.Framework"
                                    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                                    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                                    xmlns:ei="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
                                    FontFamily="{StaticResource PhoneFontFamilyNormal}"
                                    FontSize="{StaticResource PhoneFontSizeNormal}"
                                    Foreground="{StaticResource PhoneForegroundBrush}"
                                    SupportedOrientations="Portrait"
                                    Orientation="Portrait"
                                    mc:Ignorable="d"
                                    d:DesignHeight="728"
                                    d:DesignWidth="480"
                                    DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=OrderDetailsPageViewModel}">

    <i:Interaction.Behaviors>
        <behaviors:SystrayBehavior SystrayOpacity="0.5"
                                   IsBusy="{Binding IsBusy}"
                                   BusyMessage="{Binding BusyMessage}" />
    </i:Interaction.Behaviors>

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn" />
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn" />
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut" />
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut" />
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <storeControls:StoreApplicationPage.ApplicationBar>
        <shell:ApplicationBar>
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.pin.rest.png"
                                            IsEnabled="True"
                                            Text="épingler"
                                            x:Name="btnPin"
                                            Click="btnPin_Click" />
            <shell:ApplicationBarIconButton IconUri="/icons/appbar.refresh.rest.png"
                                            IsEnabled="True"
                                            Text="actualiser"
                                            x:Name="btnRefresh"
                                            Click="btnRefresh_Click" />
        </shell:ApplicationBar>
    </storeControls:StoreApplicationPage.ApplicationBar>

    <Grid x:Name="LayoutRoot"
          Background="Transparent">
        <controls:Pivot Title="{Binding Path=PageTitle, Converter={StaticResource ToUpperConverter}}">
            <i:Interaction.Behaviors>
                <behaviors:BoolValueVisibilityBehavior Value="{Binding IsBusy}"
                                                       Negate="True" />
            </i:Interaction.Behaviors>
            
            <!-- Résumé -->
            <controls:PivotItem Header="résumé"
                                Margin="12,24,12,0"
                                DataContext="{Binding OrderViewModel}">
                <Grid Margin="12,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <Grid x:Name="StateGrid"
                          d:LayoutOverrides="Height"
                          VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid Height="45"
                              Margin="0"
                              VerticalAlignment="Center"
                              Width="45">
                            <Rectangle Fill="{StaticResource AccentBrushDark}" />
                            <Rectangle Fill="{StaticResource AccentBrushLight}"
                                       Margin="6,6,-6,-6" />
                        </Grid>
                        <StackPanel Grid.Column="1"
                                    Margin="12,0,0,0">
                            <TextBlock Text="{Binding State}"
                                       TextWrapping="Wrap"
                                       Style="{StaticResource PhoneTextLargeStyle}"
                                       Foreground="{StaticResource ForegroundBrush}"  />
                            <TextBlock Text="{Binding ModificationDate}"
                                       TextWrapping="Wrap"
                                       Margin="12,-6,12,0"
                                       Style="{StaticResource PhoneTextSubtleStyle}"
                                       Foreground="{StaticResource AccentBrushDark}" />
                        </StackPanel>
                    </Grid>
                    
                    <Grid x:Name="PackageGrid"
                          Grid.Row="1"
                          VerticalAlignment="Top"
                          Margin="0,24,0,0">
                        <i:Interaction.Behaviors>
                            <behaviors:BoolValueVisibilityBehavior Value="{Binding IsShipped}" />
                        </i:Interaction.Behaviors>
                        
                        <Grid.ColumnDefinitions>
                        	<ColumnDefinition Width="*" />
                        	<ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                    	<Rectangle Fill="#FFE5E5E5"
                    		Height="100"
                    		VerticalAlignment="Top"
                    		Grid.ColumnSpan="2" />
                    	<StackPanel VerticalAlignment="Center"
                    		d:LayoutOverrides="Width"
                    		Margin="12,0">
                    		<TextBlock Style="{StaticResource PhoneTextLargeStyle}"
                    			Foreground="#FF1A1A1A"
                    			Text="Colis"/>
                    		<TextBlock Style="{StaticResource PhoneTextTitle3Style}"
                    			Foreground="{StaticResource AccentBrushDark}"
                    			FontFamily="Segoe WP Black"
                    			Text="N° 6Q00264894933"
                    			d:LayoutOverrides="Height" />
                    	</StackPanel>
                    	<Image Height="100"
                    		Source="/Assets/Images/PackageIcon.png"
                    		VerticalAlignment="Center"
                    		Grid.Column="1"
                    		HorizontalAlignment="Center" />
                    </Grid>
                    
                    <Grid x:Name="AddressGrid"
                          VerticalAlignment="Top"
                          Grid.Row="2"
                          Margin="0,24,0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid Height="45"
                              VerticalAlignment="Top"
                              Width="45" Margin="0,12,0,0">
                            <Rectangle Fill="{StaticResource AccentBrushDark}"/>
                            <Rectangle Fill="{StaticResource AccentBrushLight}"
                                       Margin="6,6,-6,-6" />
                            <Image Source="/icons/house.png"
                                   Margin="6,6,-6,-6" />
                        </Grid>
                        <StackPanel Grid.Column="1"
                                    Margin="12,0,0,0">
                            <TextBlock Text="{Binding ShippingLabel}"
                                       TextWrapping="Wrap"
                                       Style="{StaticResource PhoneTextLargeStyle}"
                                       Foreground="{StaticResource ForegroundBrush}" />
                            <TextBlock TextWrapping="Wrap"
                                       Margin="12,-6,12,0"
                                       Style="{StaticResource PhoneTextSubtleStyle}"
                                       Foreground="{StaticResource AccentBrushDark}">
                                <Run Text="{Binding ShippingFirstName}" />
                                <Run Text="{Binding ShippingLastName}" />
                                <LineBreak />
                                <Run Text="{Binding ShippingStreet}" />
                                <LineBreak />
                                <Run Text="{Binding ShippingZipCode}" />
                                <Run Text="{Binding ShippingCity}" />
                                <LineBreak />
                                <Run Text="{Binding ShippingPhone}" />
                            </TextBlock>
                        </StackPanel>
                    </Grid>
                    
                    <Border x:Name="TotalGrid"
                            Margin="0,0,0,12"
                            Background="{StaticResource AccentBrushLight}"
                            Grid.Row="3"
                            Padding="12">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="12" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="12" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}"
                                       Foreground="{StaticResource ForegroundBrush}"
                                       TextWrapping="Wrap"
                                       Text="Frais Livraison"
                                       Margin="0" 
                                       Grid.Row="0" Grid.Column="0"/>
                            <TextBlock Style="{StaticResource PhoneTextTitle3Style}"
                                       Foreground="{StaticResource ForegroundBrush}"
                                       FontFamily="Segoe WP Black"
                                       TextWrapping="Wrap"
                                       Text="MONTANT TOTAL"
                                       Margin="0"
                                       Grid.Row="2" Grid.Column="0" />
                            
                            <TextBlock Style="{StaticResource PhoneTextNormalStyle}"
                                       Foreground="{StaticResource ForegroundBrush}"
                                       TextWrapping="Wrap"
                                       Text="0 €"
                                       Margin="0"
                                       HorizontalAlignment="Right"
                                       Grid.Row="0"
                                       Grid.Column="2" />
                            <TextBlock Style="{StaticResource PhoneTextTitle3Style}"
                                       Foreground="{StaticResource ForegroundBrush}"
                                       FontFamily="Segoe WP Black"
                                       TextWrapping="Wrap"
                                       Text="{Binding TotalPrice}"
                                       Margin="0"
                                       HorizontalAlignment="Right"
                                       Grid.Row="2"
                                       Grid.Column="2" />
                        </Grid>
                    </Border>
                </Grid>
            </controls:PivotItem>

            <!-- Détails -->
            <controls:PivotItem Header="détails"
                                Margin="12,24,12,0"
                                DataContext="{Binding OrderViewModel}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <ListBox Grid.Row="0"
                             ItemsSource="{Binding Path=Products}"
                             Margin="12,0,12,12"
                             ItemTemplate="{StaticResource ProductOrderSummaryDataTemplate}" />
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>

    </Grid>
</storeControls:StoreApplicationPage>
